/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.app.controller;

import java.io.File;
import java.util.List;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.app.dto.Filter;
import org.app.utils.PropertiesHelper;
import org.gui.AutoDownloadMovieGUI;
import org.jboss.weld.environment.se.bindings.Parameters;
import org.jboss.weld.environment.se.events.ContainerInitialized;

/**
 *
 * @author LamLe
 */
public class Main {

    private static Logger logger = Logger.getLogger(Main.class);

    @Inject
    private AutoDownloadMovieGUI gui;
    public void main(@Observes ContainerInitialized event, @Parameters List parameters) {
        initialize();
        gui.setVisible(true);
    }

    private void initialize() {
        PropertyConfigurator.configure(PropertiesHelper.LOG4J_FILE_PATH);
        try {
            // init properties
            List<String> filters = FileUtils.readLines(new File("properties/filter.properties"));
            for (String s : filters) {
                Filter.add(s);
            }
        } catch (Exception e) {
            logger.error("Failed", e);
        }
    }
}
